package demo1;
/*
这是关于实例内部类相关的测试
结论：1.实例内部类不能定义静态变量 但可以使用static final进行修饰
     2.
 */
class OuterClass{
    int data1 =1;
    static int data2 = 2;
    int data3 =33;
    class InnerClass {
        int data3 = 3;
        static final int data4 =4;
        public void fun()
        {
            System.out.println(OuterClass.this.data3);
        }
    }
}
public class Test{
    public static void main(String[] args)
    {

        System.out.println(OuterClass.data2);
        System.out.println(OuterClass.InnerClass.data4);
        //实例化实例内部类的方法 1.
        //OuterClass outerClass = new OuterClass();
        //OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        //System.out.println(outerClass.data1);
        //System.out.println(outerClass.data2);
        //实例化实例内部类的方法 2.
        OuterClass.InnerClass innerClass = new OuterClass().new InnerClass();
        innerClass.fun();
        System.out.println(innerClass.data4);
        OuterClass outerclass = new OuterClass();
        System.out.println(outerclass.data1);
        System.out.println(outerclass.data2);
    }

}
